function [x,y,typ]=grayEncoder_int(job,arg1,arg2)

	x=[];y=[];typ=[]
	
	select job
		case 'plot' then
  			standard_draw(arg1)
		case 'getinputs' then
  			[x,y,typ]=standard_inputs(arg1)
		case 'getoutputs' then
  			[x,y,typ]=standard_outputs(arg1)
		case 'getorigin' then
  			[x,y]=standard_origin(arg1)
		case 'set' then
		    //set the parameters of the gray decoder
			//number of bits
			x=arg1;
			graphics=arg1.graphics;model=arg1.model;
			exprs=graphics.exprs;
			
			while %t do
				//get parameters
				[ok,num,exprs]=getvalue('Gray decoder',...
				['number of bits';],...
				list('vec',1),exprs)
				
				if ~ok then break,end;
				
				//check validity of parameters
				if num ~= floor(num) then
					message('number of bits must be a positive integer')
					ok = %f;
				end

				//write back parameters
				if ok then
					graphics.exprs=exprs
					model.dstate = grayTable(num);
					x.graphics=graphics;x.model=model
					break;
				end
			end
		case 'define' then
			num = 4;
  			exprs=[string(num)];
  			model=scicos_model()
  			model.sim=list('grayEncoder_com',5)
  			model.in = -1
  			model.out = -1
  			model.dstate = grayTable(num)
  			model.blocktype='d'
  			//model.evtin = [1];
  			model.dep_ut=[%t %t]
  			gr_i='xstringb(orig(1),orig(2),[''Gray Encoder''],sz(1),sz(2),''fill'')';
  			x=standard_define([2.5 2.5],model,exprs,gr_i)
	end
endfunction
